package com.zsrt.t05;


import java.util.List;
import org.junit.Test;

public class T05Test {
	
	/**
	 * 删除一个学生
	 * @throws Exception
	 */
	@Test
	public void deleStu() throws Exception {
		
		T05 t=new T05();
		List<StudentEntity> arryStudentList = t.getArryStudentList();
		
		//删除学生
		
		System.out.println("删除前：");
		for (StudentEntity st : arryStudentList) {
			System.out.println(st);
		}
		
		System.out.println("删除后：");
		t.delStudent("刘禅");
		for (StudentEntity st : arryStudentList) {
			System.out.println(st);
		}
	}

	/**
	 * 修改学生的分数和年龄
	 * @throws Exception
	 */
	@Test
	public void updateStu() throws Exception {
		
		T05 t=new T05();
		List<StudentEntity> arryStudentList = t.getArryStudentList();
		
		//修改学生
		System.out.println("修改前：");
		for (StudentEntity st : arryStudentList) {
			System.out.println(st);
		}
		
		System.out.println("修改后：");
		t.updateStudent("刘禅",9999,100);
		for (StudentEntity st : arryStudentList) {
			System.out.println(st);
		}
	}
	
	/**
	 * 修改学生的分数和年龄
	 * @throws Exception
	 */
	@Test
	public void searchStudent() throws Exception {
		
		T05 t=new T05();
		List<StudentEntity> arryStudentList = t.getArryStudentList();
		
		//查找学生
		List<StudentEntity> newList = t.searchStudent("刘浩");
		int size = newList.size();
		System.out.println("同姓的学生有"+size+"个");
		
		for (StudentEntity s : newList) {
			System.out.println(s);
		}
	}
	
	/**
	 * 添加一个学生
	 * @throws Exception
	 */
	@Test
	public void init() throws Exception {
		
		T05 t=new T05();
		List<StudentEntity> arryStudentList = t.getArryStudentList();
		
		StudentEntity stu=new StudentEntity("钟鹏",99,100);
		t.addStudent(stu);
		
		for (StudentEntity ss : arryStudentList) {
			System.out.println(ss);
			
		}
	}
}
